#include <bits/stdc++.h>
using namespace std;

long long n,l,r;
long long maxk,maxc = 0;

int main()
{
	freopen("candy.in","r",stdin);
	freopen("candy.out","w",stdout);
	cin >> n >> l >> r;
	for(long long i = l; i <= r; i++)
	{
		if(i % n > maxc)
		{
			maxc = i % n;
		}
	}
	cout << maxc;
}
